﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QLBN
{
    public partial class frmDSBenhNhan : Form
    {
        BenhNhan bn = new BenhNhan();
        public static Boolean  IsClick = false;
        public String MaBN = "-1";
        public frmDSBenhNhan()
        {
            InitializeComponent();
        }

        private void frmDSBenhNhan_Load(object sender, EventArgs e)
        {
            
            this.dgvdsbenhnhan.DataSource = bn.Danh_Sach_Benh_Nhan().Tables[0];
            //this.txtSoBN.Text = "Tổng số bệnh nhân: " + bn.Danh_Sach_Benh_Nhan().Tables[0].Rows.Count;
        }

        private void txttenbn_KeyUp(object sender, KeyEventArgs e)
        {
            if (this.txttenbn.Text.Replace(" ", "") == "")
            {
                this.dgvdsbenhnhan.DataSource = bn.Danh_Sach_Benh_Nhan().Tables[0];
                //this.txtSoBN.Text = "Tổng số bệnh nhân: " + bn.Danh_Sach_Benh_Nhan(this.txttenbn.Text).Tables[0].Rows.Count;
            }
            else
            {
                this.dgvdsbenhnhan.DataSource = bn.Danh_Sach_Benh_Nhan(this.txttenbn.Text).Tables[0];
                //this.txtSoBN.Text = "Số bệnh nhân hiện có: " + bn.Danh_Sach_Benh_Nhan(this.txttenbn.Text).Tables[0].Rows.Count;
            }
        }

        private void dgvdsbenhnhan_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            //MessageBox.Show(this.dgvdsbenhnhan.SelectedRows[0].Cells[0].Value.ToString());
            IsClick = true;
            this.Visible = false;
            this.MaBN = this.dgvdsbenhnhan.SelectedRows[0].Cells[0].Value.ToString();
            BenhNhan.MBN = MaBN;
        }

        private void btnXemhet_Click(object sender, EventArgs e)
        {
            this.dgvdsbenhnhan.DataSource = bn.Danh_Sach_Benh_Nhan_Full().Tables[0];
            this.txttenbn.Text = "";
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void frmDSBenhNhan_FormClosed(object sender, FormClosedEventArgs e)
        {
            IsClick = false;
            BenhNhan.IsClose = true;
        }
    }
}
